const Controller = require('egg').Controller;

class CmsController extends Controller {

  async getCategorieList() {
    const { ctx } = this;
    const [ list ] = await ctx.service.cms.getCategorieList();
    ctx.body = {
      success: true,
      list: list,
    };
  }

  async getTopList() {
    const { ctx } = this;
    
    const [ pageNum, pageSize ] = ctx.getPageInfo();
    const listQuery = {
      pageNum, pageSize,
    };
    const [ list, totalCount ] = await ctx.service.cms.getTopicList(listQuery) || [];

    ctx.apiPageList(list, totalCount);
  }

  async getTopDetail() {
    const { ctx } = this;
    const query = ctx.request.query;
    const {
      id,
    } = query;
    const [ detail, ] = await ctx.service.cms.getPubliccmsTopicDetail({ id });

    ctx.body = {
      success: true,
      data: detail,
    };
  }

  
}

module.exports = CmsController;

